package jmm.happensbefore;

/**
 * @author lizhichuan
 * @date 2024/3/21 11:13
 */
public class VolatileExample {

     int x = 0;
     boolean v = false;
     public void writer(){
          x = 42;
          v = true;
     }

     public void reader(){
         if(v == true){
            //x的值是多少呢？
            System.out.println(x);
         }
     }

     public static void main(String[] args) {
          VolatileExample volatileExample = new VolatileExample();
          volatileExample.writer();
          volatileExample.reader();
     }


}
